package com.wang.controller;

import com.wang.reponse.EvaluationReplyVo;
import com.wang.user.model.EvaluationReply;
import com.wang.user.service.EvaluationReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 评价回复控制器
 */
@RestController
@RequestMapping("/evaluation/reply")
@Api(tags = "评价回复")
public class EvaluationReplyController {

    @Resource
    private EvaluationReplyService evaluationReplyService;

    /**
     * 提交回复
     */
    @PostMapping("/submit")
    @ApiOperation(value = "提交回复")
    public Boolean submit(@RequestBody EvaluationReply reply) {
        return evaluationReplyService.submit(reply);
    }

    /**
     * 删除回复
     */
    @PostMapping("/del/{id}")
    @ApiOperation(value = "删除回复")
    public Boolean delete(@PathVariable("id") Long id) {
        return evaluationReplyService.deleteById(id);
    }

//    /**
//     * 获取评价的所有回复
//     */
//    @GetMapping("/list/{evaluationId}")
//    public List<EvaluationReplyVo> getByEvaluationId(@PathVariable Long evaluationId) {
//        List<EvaluationReply> replies = evaluationReplyService.getByEvaluationId(evaluationId);
//        return replies.stream().map(reply -> {
//            EvaluationReplyVo vo = new EvaluationReplyVo();
//            BeanUtils.copyProperties(reply, vo);
//            return vo;
//        }).collect(Collectors.toList());
//    }
} 